home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 562 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: vandevod@cs.rpi.edu (David Vandevoorde)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: The realloc question: rationale?
  5. Date: 27 Feb 1996 10:38:40 PST
  6. Organization: RPI Computer Science
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <xsoohqlz9vu.fsf@pleiades.cs.rpi.edu>
  9. References: <4g903m$7g8@mari.onr.com> <4gl2ad$lqi@hermes.synopsys.com>
  10.     <31301BFE.450A@onr.com> <xsod973w4m5.fsf@glob.cs.rpi.edu>
  11.     <9602261740.AA28201@lts.sel.alcatel.de>
  12. NNTP-Posting-Host: isolde.mti.sgi.com
  13. X-Original-Date: 26 Feb 1996 23:10:29 -0500
  14. In-Reply-To: James Kanze US/ESC 60/3/141 #40763's message of 26 Feb 1996
  15.     11:48:32 PST
  16. X-Newsreader: Gnus v5.1
  17. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  18.     iQBVAwUBMTNPx0y4NqrwXLNJAQE5dwIAhqR7MZ5zmHXLVMExh0/825NFvac0VpFh
  19.     dcMRGbEXC/wvfuvIfR3wm6gsH6NG94fMQ3lfnozkiakPLMIFyRi8ZA==
  20.     =hLTo
  21. Originator: austern@isolde.mti.sgi.com
  22.  
  23. >>>>> "JK" == James Kanze US/ESC 60/3/141 #40763 
  24.       <kanze@lts.sel.alcatel.de> writes:
  25. JK> In article <xsod973w4m5.fsf@glob.cs.rpi.edu> vandevod@cs.rpi.edu
  26. JK> (David Vandevoorde) writes:
  27. [...]
  28. JK> |> Since you can provide your own new operators etc., you can ensure that
  29. JK> |> it's safe to use realloc with new/delete (or you can provide a function
  30. JK> |> based on realloc with similar functionality).
  31. [...]
  32. JK> 1. It is, in fact, impossible to obtain the address actually returned
  33. JK> by operator new[].  The implementation is allowed to (and most do) ask
  34. JK> for extra memory in order to maintain the number of elements.
  35. JK> Typically, this memory will be in front of the first element, so the
  36. JK> compiler will `fix up' the address returned by operator new[] before
  37. JK> you ever see it.
  38.  
  39. I was aware of that... which is why I didn't claim it was portable :^P
  40. and suggested ``a function with similar functionality''.
  41.  
  42. JK> 2. The implementation is allowed to save this address in some sort of
  43. JK> cache.  For example, an alternate implementation of a new expression
  44. JK> for an array would be for the implementation to maintain an
  45. JK> associative array of addresses to counts.
  46.  
  47. That's more troublesome ;-)
  48.  
  49.     Daveed
  50. ---
  51. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  52.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  53.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  54.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  55.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  56. ]
  57.